#include "precompiled.h"
#include "DeathComponent.h"


DeathComponent::DeathComponent(void)
{
	beganDeath=false;
	finishedDeath=false;
	orderedDeath=false;
	timestamp_deathstart = numeric_limits<double>::max();
}


DeathComponent::~DeathComponent(void)
{
}


void DeathComponent::Initialize( int death_duration ){
	death_length = death_duration;
}
void DeathComponent::orderDeath(){
	orderedDeath=true;
}
void DeathComponent::doDeath( ){
	beganDeath=true;
	finishedDeath=true;

	timestamp_deathstart = last_timestamp;
}

bool DeathComponent::doingDeath(){
	if( beganDeath && !finishedDeath )
		return true;
	return false;
}

bool DeathComponent::didDeath(){
	return finishedDeath;
}


void DeathComponent::Update( GLdouble time ){
	last_timestamp = time;

	if( orderedDeath && !beganDeath){
		doDeath();
	}

	/*if( beganDeath ){

		if( time - timestamp_deathstart >= death_length ){
			printf("finished death...\n");
			finishedDeath=true;
		}
	}*/
}
